(function(){
'use strict';

/**
 * @ngdoc controller
 * @name LoginCtrl
 * @登录页面controller
 */
angular.module('controllers.login', [])
  .controller('loginController', loginCtrl);

function loginCtrl($scope, $cookies, LoginServer, $state, servicesLogin) {
  // 检查登录状态，是 ——> 跳转到主页面
  checkLog();

  //用户输入的账号密码
  $scope.user = {
    userName: '',
    pwd: ''
  };

  //避免重复点击登录按钮
  $scope.clickIf = servicesLogin.clickIf;

  /**
    * function [checkLog]  检查登录状态
   */
  function checkLog() {
    if ($cookies.getObject('userCookie') !== undefined) {
      $state.go('sas.omdisplay');
    }
  }

  /**
    * function [login]  登录
   */
  $scope.login = function () {
    $scope.clickIf.clickIf = true;
    LoginServer.loginCheck($scope.user);
  };
}
})();